package algotithm.acwing.test789;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/6-9:39
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] strings = reader.readLine().split(" ");
        int n = Integer.parseInt(strings[0]);
        int q = Integer.parseInt(strings[1]);
        String[] nums = reader.readLine().split(" ");
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = Integer.parseInt(nums[i]);
        }
        Main main = new Main();
        int[] num = new int[q];
        for (int i = 0; i < q; i++) {
            num[i] = Integer.parseInt(reader.readLine());
        }
        for (int i = 0; i < q; i++) {
            main.findNum(arr,0,n-1,num[i]);
        }
//        while (q-- > 0) {
//            int k = Integer.parseInt(reader.readLine());
//            main.findNum(arr,0,n-1,k);
//        }
        reader.close();
    }


    public  void findNum(int[] arr,int l,int r,int target) {
        while (l < r) {
            int mid = l + r >> 1;
            if (arr[mid] >= target) {
                r = mid ;
            } else {
                l = mid + 1;
            }
        }
        if (arr[l] != target) {
            System.out.println("-1 -1");
        } else {
            System.out.print(l + " ");
            l = 0;
            r = arr.length - 1;
            while (l < r) {
                int mid = l + r + 1 >> 1;
                if (arr[mid] <= target) {
                    l = mid;
                } else {
                    r = mid - 1;
                }
            }
            System.out.println(l);
        }

    }



}
